package cn.anecansaitin.not_enough_harness.common;

import cn.anecansaitin.not_enough_harness.NotEnoughHarness;
import cn.anecansaitin.not_enough_harness.common.harness_data.HarnessSpeed;
import cn.anecansaitin.not_enough_harness.common.harness_data.RushTriggerHarness;
import cn.anecansaitin.not_enough_harness.common.harness_data.SprintableHarness;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.registries.datamaps.DataMapType;
import net.neoforged.neoforge.registries.datamaps.RegisterDataMapTypesEvent;

@EventBusSubscriber(modid = NotEnoughHarness.MOD_ID)
public class ModDataMap {
    public static final DataMapType<Item, HarnessSpeed> HARNESS_SPEED =
            DataMapType.builder(
                               ResourceLocation.fromNamespaceAndPath(NotEnoughHarness.MOD_ID, "harness_speed"),
                               Registries.ITEM,
                               HarnessSpeed.CODEC
                       )
                       .synced(HarnessSpeed.SYNC_CODEC, true)
                       .build();

    public static final DataMapType<Item, SprintableHarness> SPRINTABLE_HARNESS =
            DataMapType.builder(
                               ResourceLocation.fromNamespaceAndPath(NotEnoughHarness.MOD_ID, "printable_harness"),
                               Registries.ITEM,
                               SprintableHarness.CODEC
                       )
                       .synced(SprintableHarness.SYNC_CODEC, true)
                       .build();

    public static final DataMapType<Item, RushTriggerHarness> RUSH_TRIGGER_HARNESS =
            DataMapType.builder(
                            ResourceLocation.fromNamespaceAndPath(NotEnoughHarness.MOD_ID, "rush_trigger_harness"),
                            Registries.ITEM,
                            RushTriggerHarness.CODEC
                    )
                    .synced(RushTriggerHarness.SYNC_CODEC, true)
                    .build();

    @SubscribeEvent
    public static void register(RegisterDataMapTypesEvent event) {
        event.register(HARNESS_SPEED);
        event.register(SPRINTABLE_HARNESS);
        event.register(RUSH_TRIGGER_HARNESS);
    }
}
